//
//  SINATecManagerScoreInputDetailViewController.m
//  sinashebao
//
//  Created by  androidlongs on 2018/3/6.
//  Copyright © 2018年  androidlongs. All rights reserved.
//

#import "SINATecManagerScoreInputDetailViewController.h"
#import "SINACircularBeadUtils.h"
#import "SINATecManaScoreInputTableViewCell.h"
#import "SINAScoreManagerPopView.h"

@interface SINATecManagerScoreInputDetailViewController ()<UITableViewDelegate,UITableViewDataSource>
@property (weak, nonatomic) IBOutlet UILabel *classNameLabel;

@property (weak, nonatomic) IBOutlet UILabel *commitDataLabel;
@property (weak, nonatomic) IBOutlet UITableView *tableView;

@property (weak, nonatomic) IBOutlet UILabel *noDataLabel;

@property (strong, nonatomic)  NSMutableArray *dataList;
@property (weak, nonatomic) IBOutlet UIView *codeView;
@property (weak, nonatomic) IBOutlet UILabel *scoreInputLabel;
//输入成绩确认
@property (weak, nonatomic) IBOutlet UILabel *inputScoreCommitLabel;
//点击隐藏录入
@property (weak, nonatomic) IBOutlet UIView *hindInputScoreView;
@property (weak, nonatomic) IBOutlet UIView *inputScoreMainView;
@property (weak, nonatomic) IBOutlet UILabel *inputScoreUserNameLabel;
@property (weak, nonatomic) IBOutlet UILabel *inputShowScoreUserNameLabel;
@property (weak, nonatomic) IBOutlet UILabel *inputShowScoreScoreLabel;


@property(strong,nonatomic) SINASubClassModel *currentInputScoreModel;
@property(assign,nonatomic) NSInteger currentInputScorePos;
@end

@implementation SINATecManagerScoreInputDetailViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.navigationItem.title=@"成绩录入";
    
    self.classNameLabel.text=self.mode.subjectname;
    self.commitDataLabel.backgroundColor=baseSelectColor;
    
    self.dataList = [[NSMutableArray alloc]init];
    
    
    
    self.tableView.delegate=self;
    self.tableView.dataSource=self;
    self.tableView.tableFooterView = [[UIView alloc] initWithFrame:CGRectZero];
    self.tableView.backgroundColor=[UIColor colorWithHexString:@"#fafafa"];
    self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    
    [SINACircularBeadUtils makeCircularBead:4 andView:self.commitDataLabel];
    [[SINAUiviewClickLiserner alloc]viewClickFunction:self.commitDataLabel andWithBlick:^(UIView *view) {
        [self checkCommitSubClassNetData:2];
    }];
    [self loadingSubClassNetData];
    
    self.inputScoreCommitLabel.backgroundColor=baseSelectColor;
    [SINACircularBeadUtils makeCircularBead:3 andView:self.inputScoreCommitLabel];
    
    
    
    UIView *rightView =[[UIView alloc]initWithFrame:CGRectMake(0,0,40,50)];
    UIButton *rightButton =[[UIButton alloc]initWithFrame:CGRectMake(10,0,40,35)];
    [rightButton addTarget:self action:@selector(moreDataFunction) forControlEvents:UIControlEventTouchUpInside];
    [rightView addSubview:rightButton];
    [rightButton setImage:[UIImage imageNamed:@"more_msg"] forState:UIControlStateNormal];
    UIBarButtonItem *rightButtonView = [[UIBarButtonItem alloc]initWithCustomView:rightView ];
    self.navigationItem.rightBarButtonItem=rightButtonView;
    
    
    
    NSInteger codeItemWidth = (CGRectGetWidth(self.codeView.frame)-2)/3;
    NSInteger codeItemHeight= (CGRectGetHeight(self.codeView.frame)-3)/4;
    for (NSInteger i=0; i<12; i++) {
        if (i<11) {
            UILabel *itemLabel = [[UILabel alloc]initWithFrame:CGRectMake(i%3*(codeItemWidth+1), i/3*(codeItemHeight+1), codeItemWidth, codeItemHeight)];
            itemLabel.textAlignment=NSTextAlignmentCenter;
            itemLabel.backgroundColor=[UIColor whiteColor];
            if (i<9) {
                itemLabel.text=[NSString stringWithFormat:@"%ld",(i+1)];
            } else  if (i==10){
                itemLabel.text=[NSString stringWithFormat:@"0"];
            }else{
                itemLabel.text=[NSString stringWithFormat:@"."];
            }
            
            [self.codeView addSubview:itemLabel];
            
            [[SINAUiviewClickLiserner alloc]viewClickFunction:itemLabel andWithBlick:^(UIView *view) {
                NSString *preString= self.scoreInputLabel.text;
                if ([preString isEqualToString:@"0"]) {
                    preString=@"";
                }else if ([preString isEqualToString:@"请输入成绩"]) {
                    preString=@"";
                }
                NSInteger flag=2;
                if ([preString containsString:@"."]) {
                    flag=3;
                }
                if (preString!=nil&& [preString length]>3) {
                    [YPXToastView showToastViewWithText:@"输入分数不可超出3位" andDuration:2 andParentView:itemLabel];
                    return ;
                }
                if ([itemLabel.text isEqualToString:@"."]) {
                    if ([preString isEqualToString:@"请输入成绩"]||[preString isEqualToString:@""]) {
                        preString=@"0";
                    }
                }
                self.scoreInputLabel.text = [NSString stringWithFormat:@"%@%@",preString,itemLabel.text];
                
                self.inputShowScoreScoreLabel.text =  self.scoreInputLabel.text;
            }];
        }else{
            UIView*itemLabel = [[UIView alloc]initWithFrame:CGRectMake(i%3*(codeItemWidth+1), i/3*(codeItemHeight+1), codeItemWidth, codeItemHeight)];
            [self.codeView addSubview:itemLabel];
            
            UIImageView *deleteImageView = [[UIImageView alloc]initWithFrame:CGRectMake(CGRectGetWidth(itemLabel.frame)/2-22/2, CGRectGetHeight(itemLabel.frame)/2-15/2, 22, 15)];
            itemLabel.backgroundColor=[UIColor whiteColor];
            [itemLabel addSubview:deleteImageView];
            deleteImageView.image=[UIImage imageNamed:@"number_delet"];
            [[SINAUiviewClickLiserner alloc]viewClickFunction:itemLabel andWithBlick:^(UIView *view) {
                NSString *preString= self.scoreInputLabel.text;
                if ([preString isEqualToString:@"请输入成绩"]||[preString isEqualToString:@""]) {
                    self.scoreInputLabel.text=@"请输入成绩";
                }else{
                    if (self.scoreInputLabel.text.length ==0) {
                        self.scoreInputLabel.text=@"请输入成绩";
                    } else {
                        self.scoreInputLabel.text = [self.scoreInputLabel.text substringToIndex:self.scoreInputLabel.text.length-1];
                        if (self.scoreInputLabel.text.length ==0) {
                            self.scoreInputLabel.text=@"请输入成绩";
                        }
                    }
                    
                }
                self.inputShowScoreScoreLabel.text =  self.scoreInputLabel.text;
                
            }];
        }
        
    }
    WeakSelf;
    
    weakSelf.inputScoreMainView.frame=CGRectMake(0,mainH, mainW, 0);
    
    [[SINAUiviewClickLiserner alloc]viewClickFunction:self.hindInputScoreView andWithBlick:^(UIView *view) {
        
        [UIView animateWithDuration:0.8 animations:^{
            weakSelf.inputScoreMainView.frame=CGRectMake(0,mainH, mainW, 0);
        } completion:^(BOOL finished) {
            weakSelf.inputScoreMainView.frame=CGRectMake(0,mainH, mainW, 0);
        }];
    }];
    
    dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, 0.6 * NSEC_PER_SEC);
    dispatch_after(popTime, dispatch_get_main_queue(), ^(void){
        weakSelf.inputScoreMainView.frame=CGRectMake(0,mainH, mainW, 0);
    });
    
    
    [[SINAUiviewClickLiserner alloc]viewClickFunction:self.inputScoreCommitLabel andWithBlick:^(UIView *view) {
        //确认成绩
        NSString *inputText= self.scoreInputLabel.text;
        if (inputText==nil||[inputText isEqualToString:@""]) {
            [YPXToastView showToastViewWithText:@"请输入成绩" andDuration:2 andParentView: weakSelf.inputScoreMainView];
            return ;
        }
        
        weakSelf.currentInputScoreModel.score=[inputText floatValue];
        weakSelf.currentInputScoreModel.status=@"102";
        [weakSelf.dataList replaceObjectAtIndex:weakSelf.currentInputScorePos withObject:weakSelf.currentInputScoreModel];
        
        NSIndexPath *indexPath=[NSIndexPath indexPathForRow:weakSelf.currentInputScorePos inSection:0];
        [weakSelf.tableView reloadRowsAtIndexPaths:[NSArray arrayWithObjects:indexPath,nil] withRowAnimation:UITableViewRowAnimationNone];
        
        if (weakSelf.currentInputScorePos==weakSelf.dataList.count-1) {
            [UIView animateWithDuration:0.8 animations:^{
                weakSelf.inputScoreMainView.frame=CGRectMake(0,mainH, mainW, 0);
            } completion:^(BOOL finished) {
                weakSelf.inputScoreMainView.frame=CGRectMake(0,mainH, mainW, 0);
                weakSelf.inputScoreMainView.hidden=YES;
                [YPXToastView showToastViewWithText:@"已输入完成" andDuration:2 andParentView: weakSelf.inputScoreMainView];
            }];
        } else {
            
            weakSelf.currentInputScorePos+=1;
            weakSelf.currentInputScoreModel = weakSelf.dataList[weakSelf.currentInputScorePos];
            
            weakSelf.inputScoreUserNameLabel.text = weakSelf.currentInputScoreModel.realname;
            
            CGFloat score =weakSelf.currentInputScoreModel.score;
            if (score==0) {
                weakSelf.scoreInputLabel.text=@"0";
            } else {
               weakSelf.scoreInputLabel.text = [NSString stringWithFormat:@"%0.2f",weakSelf.currentInputScoreModel.score];
            }
            
            
            weakSelf.inputShowScoreUserNameLabel.text =weakSelf.inputScoreUserNameLabel.text;
            weakSelf.inputShowScoreScoreLabel.text=weakSelf.scoreInputLabel.text;
        }
        
    }];
}
-(void)viewWillLayoutSubviews{
    //self.inputScoreMainView.frame=CGRectMake(0,mainH, mainW, 0);
}
-(void)showScoreInputView{
    WeakSelf;
    weakSelf.inputScoreMainView.hidden=NO;
    [UIView animateWithDuration:0.8 animations:^{
        weakSelf.inputScoreMainView.frame=CGRectMake(0,15, mainW, mainH-15);
    } completion:^(BOOL finished) {
        weakSelf.inputScoreMainView.frame=CGRectMake(0,15, mainW, mainH-15);
        
    }];
}
-(void)hindScoreInputView{
    WeakSelf;
    
    [UIView animateWithDuration:0.8 animations:^{
        weakSelf.inputScoreMainView.frame=CGRectMake(0,mainH, mainW, mainH-15);
    } completion:^(BOOL finished) {
        weakSelf.inputScoreMainView.hidden=YES;
        weakSelf.inputScoreMainView.frame=CGRectMake(0,mainH, mainW, mainH-15);
        
    }];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return self.dataList.count;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    
    SINATecManaScoreInputTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"SINATecManaScoreInputTableViewCell"];
    
    if (cell == nil) {
        cell= [[[NSBundle mainBundle]loadNibNamed:@"SINATecManaScoreInputTableViewCell" owner:nil options:nil] firstObject];
        
    }
    cell.itemClickBlock = ^(NSInteger pos,SINASubClassModel *model) {
        
        self.inputScoreUserNameLabel.text = model.realname;
        self.inputShowScoreUserNameLabel.text = model.realname;
        
        if (model.score==0) {
            self.scoreInputLabel.text = [NSString stringWithFormat:@"%@",@""];
            self.inputShowScoreScoreLabel.text = [NSString stringWithFormat:@"%@",@""];
        } else {
            self.scoreInputLabel.text = [NSString stringWithFormat:@"%0.2f",model.score];
            self.inputShowScoreScoreLabel.text = [NSString stringWithFormat:@"%0.2f",model.score];
        }
        
        
        self.currentInputScorePos=pos;
        self.currentInputScoreModel = model;
        
        
        [self showScoreInputView];
        
        
    };
    cell.pos=indexPath.row;
    cell.model = self.dataList[indexPath.row];
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    return cell ;
    
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 48;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(nonnull NSIndexPath *)indexPath{
    //    NSInteger index = indexPath.row;
    
}


-(void)loadingSubClassNetData{
    
    [self startLoading];
    NSMutableDictionary *dict = [[NSMutableDictionary alloc]init];
    
    [dict setObject:self.mode.subjectid forKey:@"subjectid"];
    
    WeakSelf;
    [CXAFNHttpRequestUtils httpGetRequest:[NSString stringWithFormat:@"%@%@",baseUrl,getNameAndScoreBySubjectidUrl] withParamters:dict success:^(id responseData) {
        
        [weakSelf stopLoading];
        NSString *code = responseData[@"code"];
        
        if ([code isEqualToString:@"1000"]) {
            NSMutableArray *result = responseData[@"content"];
            if (result!=nil&&result.count>0) {
                for (NSInteger i=0; i<result.count; i++) {
                    NSDictionary *dict=result[i];
                    SINASubClassModel *model = [[SINASubClassModel alloc]initWithDict:dict];
                    [self.dataList addObject:model];
                }
                self.noDataLabel.hidden=YES;
                self.tableView.hidden=NO;
                [self.tableView reloadData];
            }else{
                self.noDataLabel.hidden=NO;
                self.tableView.hidden=YES;
            }
            
        }else{
            //            NSString *message =responseData[@"message"];
            //            WISAlertView *alertView =   [[WISAlertView alloc]initWithTitle:@"提示" message:message sureBtn:@"确定"
            //                                                                 cancleBtn:nil];
            //[alertView showXLAlertView];
            self.noDataLabel.hidden=NO;
            self.tableView.hidden=YES;
        }
        
        
        
    } failure:^(NSError *error, NSInteger errCode) {
        DLog(@"加载 失败  %@ ",error.debugDescription);
        [weakSelf stopLoading];
        //        WISAlertView *alertView =   [[WISAlertView alloc]initWithTitle:@"提示" message:@"加载数据失败" sureBtn:@"确定"
        //                                                             cancleBtn:nil];
        //[alertView showXLAlertView];
        self.noDataLabel.hidden=NO;
        self.tableView.hidden=YES;
    }];
}

-(void)checkCommitSubClassNetData:(NSInteger) indexFlag{
    
    BOOL isFlag = YES;
    
    for (NSInteger i=0; i<self.dataList.count; i++) {
        SINASubClassModel *model = self.dataList[i];
        if (model.status==nil||[model.status isEqualToString:@""]) {
            isFlag=NO;
        }
    }
    WISAlertView *alertView =   [[WISAlertView alloc]initWithTitle:@"提示" message:@"有未输入学生的成绩 默认提交为0分" sureBtn:@"提交"
                                                                                              cancleBtn:@"取消"];
    alertView.resultIndex = ^(NSInteger index) {
        [self commitSubClassNetData:indexFlag];
    };
    if (isFlag) {
        [self commitSubClassNetData:indexFlag];
    } else {
           [alertView showXLAlertView];
    }
    
    
}

//提交成绩信息
-(void)commitSubClassNetData:(NSInteger) indexFlag{
    
   
    
    WeakSelf;
    
    
    [self hindScoreInputView];
    
    NSMutableDictionary *dict = [[NSMutableDictionary alloc]init];
    
    
    NSString *studentuuid=@"";
    NSString *score=@"";
    
    for (NSInteger i=0; i<self.dataList.count; i++) {
        SINASubClassModel *model = self.dataList[i];
        if (i!=0) {
            studentuuid = [NSString stringWithFormat:@"%@,%@",studentuuid,model.uuid];
            score = [NSString stringWithFormat:@"%@,%0.2f",score,model.score];
        } else {
            studentuuid=model.uuid;
            score=[NSString stringWithFormat:@"%0.2f",model.score];
        }
        
    }
    
    SINAUserModel *usermodel = [[SINACommonUserHelper share]getUserModel];
    
    //老师名
    [dict setObject:usermodel.userRealName forKey:@"teachername"];
    //科目名
    [dict setObject:self.mode.subjectname forKey:@"subjectname"];
    
    //学生uuid String studentuuid： 用逗号分隔所有学生信息
    [dict setObject:studentuuid forKey:@"studentuuid"];
    //学生成绩 String score： 用逗号分隔对应学生成绩信息
    [dict setObject:score forKey:@"score"];
    //老师uuid String teacheruuid
    [dict setObject:[NSString stringWithFormat:@"%@",self.mode.subjectid] forKey:@"subjectid"];
    //科目id String subjectid
    [dict setObject:[[SINACommonUserHelper share]getUserModel].userUid forKey:@"teacheruuid"];
    if (indexFlag==0) {
        //状态 String status : 1000 保存； 1001 发布成绩
        [dict setObject:[NSString stringWithFormat:@"%@",@"1000"] forKey:@"status"];
    }else if (indexFlag==1) {
        //状态 String status : 1000 保存； 1001 发布成绩
        [dict setObject:[NSString stringWithFormat:@"%@",@"1001"] forKey:@"status"];
    } else {
        //状态 String status : 1000 保存； 1001 发布成绩
        [dict setObject:[NSString stringWithFormat:@"%@",@"1001"] forKey:@"status"];
    }
   
    NSMutableDictionary *dict2 = [[NSMutableDictionary alloc]init];
    
    [dict2 setObject:[SINAHttpRequestUtils encodeDicParams:dict] forKey:@"sj"];
    
    [self startLoading];
    
    [CXAFNHttpRequestUtils httpPostRequest:[NSString stringWithFormat:@"%@%@",baseUrl,assStudentScoreUrl] withParamters:dict2 success:^(id responseData) {
        
        NSString *code = responseData[@"code"];
        
        [weakSelf stopLoading];
        
        if ([code isEqualToString:@"1000"]) {
//            self.loadingView.text=@"成绩提交成功";
            
            [YPXToastView showToastViewWithText:@"成绩提交成功" andDuration:2 andCorner:5 andParentView:weakSelf.view];
            
            dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, 1 * NSEC_PER_SEC);
            dispatch_after(popTime, dispatch_get_main_queue(), ^(void){
//
                [weakSelf stopLoading];
                //[weakSelf.navigationController popViewControllerAnimated:YES];
            });
           
           
            
        }else{
       
            [weakSelf stopLoading];
            NSString *message =responseData[@"message"];
            WISAlertView *alertView =   [[WISAlertView alloc]initWithTitle:@"提示" message:message sureBtn:@"确定"
                                                                 cancleBtn:nil];
            [alertView showXLAlertView];
        }
        
        
        
    } failure:^(NSError *error, NSInteger errCode) {

        [weakSelf stopLoading];
        WISAlertView *alertView =   [[WISAlertView alloc]initWithTitle:@"提示" message:@"提交数据失败" sureBtn:@"确定"
                                                             cancleBtn:nil];
        [alertView showXLAlertView];
        
    }];
}

//sendScoreMessageUrl
//发布成绩后发送消息推送通知
-(void)sendScoreMessageFunction{
    
    DLog(@"发布消息");
    
     NSMutableDictionary *dict = [[NSMutableDictionary alloc]init];
    
    NSString *studentuuid=@"";
    NSString *score=@"";
    
    for (NSInteger i=0; i<self.dataList.count; i++) {
        SINASubClassModel *model = self.dataList[i];
        if (i!=0) {
            studentuuid = [NSString stringWithFormat:@"%@,%@",studentuuid,model.uuid];
            score = [NSString stringWithFormat:@"%@,%0.2f",score,model.score];
        } else {
            studentuuid=model.uuid;
            score=[NSString stringWithFormat:@"%0.2f",model.score];
        }
        
    }
    //学生uuid String studentuuid： 用逗号分隔所有学生信息
    [dict setObject:studentuuid forKey:@"studentuuid"];
    //学生成绩 String score： 用逗号分隔对应学生成绩信息
    [dict setObject:score forKey:@"score"];
    SINAUserModel *usermodel = [[SINACommonUserHelper share]getUserModel];
    
    //老师名
    [dict setObject:usermodel.userRealName forKey:@"teachername"];
    //科目名
    [dict setObject:self.mode.subjectname forKey:@"subjectname"];
    
    [self startLoading];
    WeakSelf;
    [CXAFNHttpRequestUtils httpGetRequest:[NSString stringWithFormat:@"%@%@",baseUrl,sendScoreMessageUrl] withParamters:dict success:^(id responseData) {
        [weakSelf stopLoading];
        NSString *code = responseData[@"code"];
        
        if ([code isEqualToString:@"1000"]) {
            DLog(@"发送通知成功");
//            self.loadingView.text=@"发送成绩通知成功";
            
             [YPXToastView showToastViewWithText:@"发送成绩通知成功" andDuration:2 andCorner:5 andParentView:weakSelf.view];
            
            dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, 1 * NSEC_PER_SEC);
            dispatch_after(popTime, dispatch_get_main_queue(), ^(void){
                //[weakSelf.navigationController popViewControllerAnimated:YES];
            });
            
        }else{
           DLog(@"发送通知失败");
//            self.loadingView.text=@"发送成绩通知失败";
            [YPXToastView showToastViewWithText:@"发送成绩通知失败" andDuration:2 andCorner:5 andParentView:weakSelf.view];
            dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, 1 * NSEC_PER_SEC);
            dispatch_after(popTime, dispatch_get_main_queue(), ^(void){
                //[weakSelf.navigationController popViewControllerAnimated:YES];
            });
        }
        
        
        
    } failure:^(NSError *error, NSInteger errCode) {
        [weakSelf stopLoading];
//        self.loadingView.text=@"发送成绩通知失败";
        [YPXToastView showToastViewWithText:@"发送成绩通知失败" andDuration:2 andCorner:5 andParentView:weakSelf.view];
         DLog(@"发送通知失败");
        dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, 1 * NSEC_PER_SEC);
        dispatch_after(popTime, dispatch_get_main_queue(), ^(void){
            //[weakSelf.navigationController popViewControllerAnimated:YES];
        });
    }];
}


-(void)moreDataFunction{
    SINAScoreManagerPopView *popView =[[SINAScoreManagerPopView alloc]init];
   
    
    WeakSelf;
    popView.saveScoreBlock = ^{
        DLog(@"保存成绩");
        [weakSelf checkCommitSubClassNetData:0];
    };
    
    popView.uploadBlock = ^{
        DLog(@"发布成绩");
        //[weakSelf checkCommitSubClassNetData:1];
        BOOL isFlag = YES;
        
        for (NSInteger i=0; i<weakSelf.dataList.count; i++) {
            SINASubClassModel *model = weakSelf.dataList[i];
            if (model.status==nil||[model.status isEqualToString:@""]) {
                isFlag=NO;
            }
        }
        WISAlertView *alertView =   [[WISAlertView alloc]initWithTitle:@"提示" message:@"有未输入学生的成绩 默认提交为0分" sureBtn:@"提交"
                                                             cancleBtn:@"取消"];
        alertView.resultIndex = ^(NSInteger index) {
            [weakSelf sendScoreMessageFunction ];
        };
        if (isFlag) {
           [weakSelf sendScoreMessageFunction ];
        } else {
            [alertView showXLAlertView];
        }
        
    };
    
     [popView show];
    
}
/*
 #pragma mark - Navigation
 
 // In a storyboard-based application, you will often want to do a little preparation before navigation
 - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
 // Get the new view controller using [segue destinationViewController].
 // Pass the selected object to the new view controller.
 }
 */

@end
